package cn.sc.summer.system.task;

import cn.sc.summer.system.condition.SystemCondition;
import cn.sc.summer.system.service.RefreshSystemInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Conditional;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 类名：定时刷新服务器资源信息
 *
 * @author a-xin
 * @date 2023/10/24 15:10
 */
@Slf4j
@Component
@Conditional(SystemCondition.class)
public class RefreshSystemInfoTask {

    @Resource
    private RefreshSystemInfoService refreshSystemInfoService;

    /**
     * 定时任务，每1分钟刷新一次服务器系统基础信息
     */
    @Scheduled(cron = "0 0/1 * * * ?")
    public void refreshSystemInfo() {
        log.info("-> Starts collecting server resource information...");
        refreshSystemInfoService.refreshSystemInfo();
    }

}
